/**
 * Created by zl206 on 2016/11/5.
 */


function bg() {
    var bgw=240;
    var sX=bgw-wX%bgw;
    var sY=bgw-wY%bgw;
    var stop=0;
    var sbottom=dH;
    var sleft=0;
    var sright=dW;
    if(wX<0){
        sleft=-wX;
        sX=-wX;
    }
    if (wY<0){
        stop=-wY;
        sY=-wY;
    }
    if(wX>bgW-dW){
        sright=bgW-wX;
    }
    if(wY>bgH-dH){
        sbottom=bgH-wY;
    }
    var num=0;
    cxt.beginPath();
    cxt.strokeStyle="rgba(145,145,145,.3)";
    while (true){
        var tempX=sX+num*bgw;
        var tempY=sY+num++*bgw;
        if(tempX>dW&&tempY>dH)
            break;
        if(tempX<=dW&&wX+tempX<=bgW){
            cxt.moveTo(tempX,stop);
            cxt.lineTo(tempX,sbottom);
        }
        if(tempY<=dH&&wY+tempY<=bgH){
            cxt.moveTo(sleft,tempY);
            cxt.lineTo(sright,tempY);
        }
        cxt.stroke();
    }
    
}